# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=harfbuzz
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.9.29
pkgrel=1
pkgdesc="OpenType text shaping engine (mingw-w64)"
arch=('any')
url="http://www.freedesktop.org/wiki/Software/HarfBuzz"
license=("MIT")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
            "${MINGW_PACKAGE_PREFIX}-pkg-config"
            "${MINGW_PACKAGE_PREFIX}-icu"
            "${MINGW_PACKAGE_PREFIX}-gobject-introspection")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
        "${MINGW_PACKAGE_PREFIX}-glib2"
        "${MINGW_PACKAGE_PREFIX}-freetype"
        "${MINGW_PACKAGE_PREFIX}-cairo")
options=('strip' 'staticlibs')
optdepends=("${MINGW_PACKAGE_PREFIX}-icu: harfbuzz-icu")
source=("http://www.freedesktop.org/software/harfbuzz/release/${_realname}-${pkgver}.tar.bz2"
        0001-give-cc-to-gir-scanner.all.patch)
sha256sums=('601cea38c6fa0cf362dd9042c66cf4db711c5f9390de4ca46d6d2fc3f64de390'
            'e9b8a59dfea6fa742b30d5cb99a42c80007941573d6f0ce51717f7243d801acd')

prepare() {
  cd "${srcdir}//${_realname}-${pkgver}"
  patch -p1 -i ${srcdir}/0001-give-cc-to-gir-scanner.all.patch
  autoreconf -fi
}

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  "${srcdir}"/${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --enable-static \
    --enable-introspection=auto \
    --with-gobject
  make
}

check(){
  cd "${srcdir}/build-${MINGW_CHOST}"
  make check
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="$pkgdir" install
  find "${pkgdir}${MINGW_PREFIX}" -name '*.def' -o -name '*.exp' | xargs -rtl1 rm
}
